//
//  LTMyPhoneViewController.m
//  Learn
//
//  Created by zyl_macbookpro on 2024/3/30.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "LTMyPhoneViewController.h"
//#import "LoginAPIManager.h"
//#import "LoginHistoryAccountView.h"

@interface LTMyPhoneViewController ()<UITextFieldDelegate ,UITableViewDelegate,UITableViewDataSource>

@property(nonatomic ,strong)UITableView *tableView;

@property(nonatomic ,strong)UIView *tableHeaderView;

@property(nonatomic ,strong)UIView *tableFootorView;

@property(nonatomic ,strong)UIButton *changeButton;

@end

@implementation LTMyPhoneViewController
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
  
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
}

- (void)viewDidLoad
{
    [super viewDidLoad];
   
    [self.view addSubview:self.tableView];
    [self setBackButtonIsHidden:NO];

}

#pragma mark -UITableViewDelegate,UITableViewDelegate
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell =nil;
    
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@""];
        cell.selectionStyle =UITableViewCellSelectionStyleNone;
    }
    [cell.contentView removeAllSubviews];
   
    
    return cell;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
        return 0;
        
  
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 61;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{


}



#pragma mark -UITextFieldDelegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
    //[[textField viewWithTag:1001] setBackgroundColor:kOrangeLineColor];
}

-(BOOL)textFieldShouldEndEditing:(UITextField *)textField{
    //[[textField viewWithTag:1001] setBackgroundColor:kLineColor];
    
    return  YES;
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    return YES;
}
#pragma mark - private

#pragma mark -event response

- (void)tapClick
{
    [self.view endEditing:YES];
}

- (void)changeButtonAction
{
    [self.view endEditing:YES];
    self.view.backgroundColor = LTWhiteColor;
    [self pushToViewControllerWithClassName:@"LTChangeMyPhoneNumberVC" animated:YES];
}

-(void)textFieldResignTapAction:(UITapGestureRecognizer *)sender
{
    [self.view endEditing:YES];
}
-(void)textEnd:(UITextField *)textField
{
    [self.tableView reloadData];
}
-(void)textChanged:(UITextField *)textField
{
    
  //  [self changeLoginBtnStatue];
}
#pragma mark -getters and setters
-(UITableView *)tableView{
    if (!_tableView){
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, LTTopBarHeight, LTScreenWidth, LTScreenHeight - LTTopBarHeight) style:UITableViewStylePlain];
        [_tableView setDelegate:self];
        [_tableView setDataSource:self];
        _tableView.bounces = NO;
        [_tableView setBackgroundColor:LTWhiteColor];
        [_tableView setSeparatorColor:LTClearColor];
        [_tableView setTableHeaderView:self.tableHeaderView];
        [_tableView setTableFooterView:self.tableFootorView];
    }
    
    return _tableView;
}

-(UIView *)tableHeaderView
{
    if (!_tableHeaderView)
    {
        
        _tableHeaderView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, LTScreenWidth,210)];
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick)];
            [_tableHeaderView addGestureRecognizer:tap];
    
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(32, 64, LTScreenWidth - 64, 40)];
        titleLabel.font = SFontWithSize(28);
        if (LTApp.mobile.length > 0) {
            titleLabel.text = [LTApp.mobile stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
        }
       
        [titleLabel setTextAlignment:NSTextAlignmentCenter];
        titleLabel.textColor = LTTextBlack;
        
        UILabel * subLabel = [[UILabel alloc] initWithFrame:CGRectMake(32, titleLabel.bottom + 8, LTScreenWidth - 64, 18)];
        subLabel.font = RFontWithSize(13);
        subLabel.text = @"当前手机号为";
        [subLabel setTextAlignment:NSTextAlignmentCenter];
        subLabel.textColor = rgba(102, 102, 102, 1);
        [_tableHeaderView addSubview:titleLabel];
        [_tableHeaderView addSubview:subLabel];
        
        _tableHeaderView.height = subLabel.bottom;
       
    }
    
    return _tableHeaderView;
}

-(UIView *)tableFootorView
{
    if (!_tableFootorView)
    {
        _tableFootorView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, LTScreenWidth - 20, 20)];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick)];
        [_tableFootorView addGestureRecognizer:tap];
       
        [_tableFootorView addSubview:self.changeButton];
      
        _tableFootorView.height = self.changeButton.bottom;
    }
    
    return _tableFootorView;
}

-(UIButton *)changeButton
{
    if (!_changeButton)
    {
        _changeButton = [UIButton new];
        _changeButton.frame =CGRectMake(32, 45, LTScreenWidth - 64, 44);
       
        [_changeButton setTitle:@"更换手机号" forState:UIControlStateNormal];
       // [_changeButton setTitleColor:rgba(181, 181, 181, 1) forState:UIControlStateNormal];
        [_changeButton setTitleColor:LTWhiteColor forState:UIControlStateNormal];
        [_changeButton.titleLabel setFont:MFontWithSize(14)];
        [_changeButton addTarget:self action:@selector(changeButtonAction) forControlEvents:UIControlEventTouchUpInside];
        _changeButton.backgroundColor = rgba(41, 121, 255, 1);
        _changeButton.layer.cornerRadius = 22;
        _changeButton.layer.shadowColor = rgba(41, 121, 255, 0.50).CGColor;
        _changeButton.layer.shadowOffset = CGSizeMake(0,4);
        _changeButton.layer.shadowOpacity = 1;
        _changeButton.layer.shadowRadius = 6;
    }
    
    return _changeButton;
}

@end
